package com.mo.controller;

import com.mo.DlykApplication;
import com.mo.model.TActivity;
import com.mo.model.TDicValue;
import com.mo.model.TProduct;
import com.mo.result.DicEnum;
import com.mo.result.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author mo
 * version
 */
@RestController
public class DicController {

    @GetMapping(value = "/api/dicvalue/{typeCode}")
    public R dicData(@PathVariable (value = "typeCode") String typeCode ){
        if (typeCode.equals(DicEnum.ACTIVITY.getCode())){
            List<TActivity> tDicValueList = (List<TActivity>) DlykApplication.cacheMap.get(typeCode);
            return R.OK(tDicValueList);
        }else if(typeCode.equals(DicEnum.PRODUCT.getCode())){
            List<TProduct> tDicValueList = (List<TProduct>) DlykApplication.cacheMap.get(typeCode);
            return R.OK(tDicValueList);
        }
        List<TDicValue> tDicValueList = (List<TDicValue>) DlykApplication.cacheMap.get(typeCode);
        return R.OK(tDicValueList);
    }
}
